class Cat(object):
    def say(self):
        print('i am a cat')

class Dog(object):
    def say(self):
        print('i am a dog')
    def __getitem__(self, item):
        return 'bobby'

class Duck(object):
    def say(self):
        print('i am a duck')
class Company(object):
    def __init__(self,employee_list):
        self.employee=employee_list
    def __getitem__(self, item):#是类对象变成可迭代类型，可以直接for循环类对象
        return self.employee[item]#会把index传给item
    def __len__(self):
        return len(self.employee)

    def __str__(self):
        return ",".join(self.employee)

    def __repr__(self):
        return ",".join(self.employee)
company=Company(['tom','bob','jane'])
print(company.__dict__)
print(Company.__dict__)
company1=company[:2]
for em in company1:
    print(em)
print(company)

animal_list=[Cat,Dog,Duck]
for animal in animal_list:
    animal().say()
dog=Dog()
class Animal():
    def say(self):
        print('i am a animal')

class Cat(Animal):
    def say(self):
        print('i am a cat')

Animal_an=Cat()
Animal_an.say()

a=['bobby1','bobby2']
b=['bobby1','bobby2']
name_tuple=("bobby3","bobby4")
name_set=set()
name_set.add("bobby5")
name_set.add("bobby6")
a.extend(company)
print(a)


